package com.apollographql.apollo.internal;

import com.apollographql.apollo.ApolloCall;
import com.apollographql.apollo.ApolloMutationCall;
import com.apollographql.apollo.ApolloQueryCall;
import com.apollographql.apollo.api.Mutation;
import com.apollographql.apollo.api.Operation;
import com.apollographql.apollo.api.OperationName;
import com.apollographql.apollo.api.Query;
import com.apollographql.apollo.api.ScalarTypeAdapters;
import com.apollographql.apollo.api.cache.http.HttpCache;
import com.apollographql.apollo.api.cache.http.HttpCachePolicy;
import com.apollographql.apollo.api.internal.Action;
import com.apollographql.apollo.api.internal.ApolloLogger;
import com.apollographql.apollo.api.internal.Optional;
import com.apollographql.apollo.api.internal.ResponseFieldMapper;
import com.apollographql.apollo.api.internal.Utils;
import com.apollographql.apollo.cache.CacheHeaders;
import com.apollographql.apollo.cache.normalized.ApolloStore;
import com.apollographql.apollo.exception.ApolloCanceledException;
import com.apollographql.apollo.exception.ApolloException;
import com.apollographql.apollo.exception.ApolloHttpException;
import com.apollographql.apollo.exception.ApolloNetworkException;
import com.apollographql.apollo.exception.ApolloParseException;
import com.apollographql.apollo.fetcher.ApolloResponseFetchers;
import com.apollographql.apollo.fetcher.ResponseFetcher;
import com.apollographql.apollo.interceptor.ApolloAutoPersistedOperationInterceptor;
import com.apollographql.apollo.interceptor.ApolloInterceptor;
import com.apollographql.apollo.interceptor.ApolloInterceptorChain;
import com.apollographql.apollo.interceptor.ApolloInterceptorFactory;
import com.apollographql.apollo.internal.CallState;
import com.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor;
import com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor;
import com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor;
import com.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain;
import com.apollographql.apollo.request.RequestHeaders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicReference;
import okhttp3.Call;
import okhttp3.HttpUrl;

public final class RealApolloCall<T> implements ApolloQueryCall<T>, ApolloMutationCall<T> {
    final ApolloStore apolloStore;
    final List<ApolloInterceptorFactory> applicationInterceptorFactories;
    final List<ApolloInterceptor> applicationInterceptors;
    final ApolloInterceptorFactory autoPersistedOperationsInterceptorFactory;
    final CacheHeaders cacheHeaders;
    final Executor dispatcher;
    final boolean enableAutoPersistedQueries;
    final HttpCache httpCache;
    final HttpCachePolicy.Policy httpCachePolicy;
    final Call.Factory httpCallFactory;
    final ApolloInterceptorChain interceptorChain;
    final ApolloLogger logger;
    final Operation operation;
    final Optional<Operation.Data> optimisticUpdates;
    final AtomicReference<ApolloCall.Callback<T>> originalCallback = new AtomicReference<>();
    final Optional<QueryReFetcher> queryReFetcher;
    final List<Query> refetchQueries;
    final List<OperationName> refetchQueryNames;
    final RequestHeaders requestHeaders;
    final ResponseFetcher responseFetcher;
    final ScalarTypeAdapters scalarTypeAdapters;
    final HttpUrl serverUrl;
    final AtomicReference<CallState> state = new AtomicReference<>(CallState.IDLE);
    final ApolloCallTracker tracker;
    final boolean useHttpGetMethodForPersistedQueries;
    final boolean useHttpGetMethodForQueries;
    final boolean writeToNormalizedCacheAsynchronously;

    public static <T> Builder<T> builder() {
        return new Builder<>();
    }

    RealApolloCall(Builder<T> builder) {
        this.operation = builder.operation;
        this.serverUrl = builder.serverUrl;
        this.httpCallFactory = builder.httpCallFactory;
        this.httpCache = builder.httpCache;
        this.httpCachePolicy = builder.httpCachePolicy;
        this.scalarTypeAdapters = builder.scalarTypeAdapters;
        this.apolloStore = builder.apolloStore;
        this.responseFetcher = builder.responseFetcher;
        this.cacheHeaders = builder.cacheHeaders;
        this.requestHeaders = builder.requestHeaders;
        this.dispatcher = builder.dispatcher;
        this.logger = builder.logger;
        this.applicationInterceptors = builder.applicationInterceptors;
        this.applicationInterceptorFactories = builder.applicationInterceptorFactories;
        this.autoPersistedOperationsInterceptorFactory = builder.autoPersistedOperationsInterceptorFactory;
        this.refetchQueryNames = builder.refetchQueryNames;
        this.refetchQueries = builder.refetchQueries;
        this.tracker = builder.tracker;
        if ((!this.refetchQueries.isEmpty() || !this.refetchQueryNames.isEmpty()) && builder.apolloStore != null) {
            this.queryReFetcher = Optional.of(QueryReFetcher.builder().queries(builder.refetchQueries).queryWatchers(this.refetchQueryNames).serverUrl(builder.serverUrl).httpCallFactory(builder.httpCallFactory).scalarTypeAdapters(builder.scalarTypeAdapters).apolloStore(builder.apolloStore).dispatcher(builder.dispatcher).logger(builder.logger).applicationInterceptors(builder.applicationInterceptors).applicationInterceptorFactories(builder.applicationInterceptorFactories).autoPersistedOperationsInterceptorFactory(builder.autoPersistedOperationsInterceptorFactory).callTracker(builder.tracker).build());
        } else {
            this.queryReFetcher = Optional.absent();
        }
        this.useHttpGetMethodForQueries = builder.useHttpGetMethodForQueries;
        this.enableAutoPersistedQueries = builder.enableAutoPersistedQueries;
        this.useHttpGetMethodForPersistedQueries = builder.useHttpGetMethodForPersistedQueries;
        this.optimisticUpdates = builder.optimisticUpdates;
        this.writeToNormalizedCacheAsynchronously = builder.writeToNormalizedCacheAsynchronously;
        this.interceptorChain = prepareInterceptorChain(this.operation);
    }

    @Override // com.apollographql.apollo.ApolloCall
    public void enqueue(ApolloCall.Callback<T> responseCallback) {
        try {
            activate(Optional.fromNullable(responseCallback));
            this.interceptorChain.proceedAsync(ApolloInterceptor.InterceptorRequest.builder(this.operation).cacheHeaders(this.cacheHeaders).requestHeaders(this.requestHeaders).fetchFromCache(false).optimisticUpdates(this.optimisticUpdates).useHttpGetMethodForQueries(this.useHttpGetMethodForQueries).build(), this.dispatcher, interceptorCallbackProxy());
        } catch (ApolloCanceledException e) {
            if (responseCallback != null) {
                responseCallback.onCanceledError(e);
                return;
            }
            this.logger.e(e, "Operation: %s was canceled", operation().name().name());
        }
    }

    @Override // com.apollographql.apollo.ApolloQueryCall
    public RealApolloQueryWatcher<T> watcher() {
        return new RealApolloQueryWatcher<>(clone(), this.apolloStore, this.logger, this.tracker, ApolloResponseFetchers.CACHE_FIRST);
    }

    @Override // com.apollographql.apollo.ApolloQueryCall
    public RealApolloCall<T> httpCachePolicy(HttpCachePolicy.Policy httpCachePolicy2) {
        if (this.state.get() == CallState.IDLE) {
            return toBuilder().httpCachePolicy((HttpCachePolicy.Policy) Utils.checkNotNull(httpCachePolicy2, "httpCachePolicy == null")).build();
        }
        throw new IllegalStateException("Already Executed");
    }

    @Override // com.apollographql.apollo.ApolloQueryCall
    public RealApolloCall<T> responseFetcher(ResponseFetcher fetcher) {
        if (this.state.get() == CallState.IDLE) {
            return toBuilder().responseFetcher((ResponseFetcher) Utils.checkNotNull(fetcher, "responseFetcher == null")).build();
        }
        throw new IllegalStateException("Already Executed");
    }

    @Override // com.apollographql.apollo.ApolloQueryCall, com.apollographql.apollo.ApolloCall, com.apollographql.apollo.ApolloMutationCall
    public RealApolloCall<T> cacheHeaders(CacheHeaders cacheHeaders2) {
        if (this.state.get() == CallState.IDLE) {
            return toBuilder().cacheHeaders((CacheHeaders) Utils.checkNotNull(cacheHeaders2, "cacheHeaders == null")).build();
        }
        throw new IllegalStateException("Already Executed");
    }

    @Override // com.apollographql.apollo.ApolloQueryCall, com.apollographql.apollo.ApolloMutationCall
    public RealApolloCall<T> requestHeaders(RequestHeaders requestHeaders2) {
        if (this.state.get() == CallState.IDLE) {
            return toBuilder().requestHeaders((RequestHeaders) Utils.checkNotNull(requestHeaders2, "requestHeaders == null")).build();
        }
        throw new IllegalStateException("Already Executed");
    }

    @Override // com.apollographql.apollo.internal.util.Cancelable, com.apollographql.apollo.ApolloCall
    public synchronized void cancel() {
        int i = AnonymousClass3.$SwitchMap$com$apollographql$apollo$internal$CallState[this.state.get().ordinal()];
        if (i == 1) {
            this.state.set(CallState.CANCELED);
            try {
                this.interceptorChain.dispose();
                if (this.queryReFetcher.isPresent()) {
                    this.queryReFetcher.get().cancel();
                }
            } finally {
                this.tracker.unregisterCall(this);
                this.originalCallback.set(null);
            }
        } else if (i == 2) {
            this.state.set(CallState.CANCELED);
        } else if (i != 3) {
            if (i != 4) {
                throw new IllegalStateException("Unknown state");
            }
        }
    }

    @Override // com.apollographql.apollo.internal.util.Cancelable
    public boolean isCanceled() {
        return this.state.get() == CallState.CANCELED;
    }

    @Override // com.apollographql.apollo.ApolloQueryCall, com.apollographql.apollo.ApolloCall, com.apollographql.apollo.ApolloMutationCall
    public RealApolloCall<T> clone() {
        return toBuilder().build();
    }

    @Override // com.apollographql.apollo.ApolloMutationCall
    public ApolloMutationCall<T> refetchQueries(OperationName... operationNames) {
        if (this.state.get() == CallState.IDLE) {
            return toBuilder().refetchQueryNames(Arrays.asList(Utils.checkNotNull(operationNames, "operationNames == null"))).build();
        }
        throw new IllegalStateException("Already Executed");
    }

    @Override // com.apollographql.apollo.ApolloMutationCall
    public ApolloMutationCall<T> refetchQueries(Query... queries) {
        if (this.state.get() == CallState.IDLE) {
            return toBuilder().refetchQueries(Arrays.asList( Utils.checkNotNull(queries, "queries == null"))).build();
        }
        throw new IllegalStateException("Already Executed");
    }

    @Override // com.apollographql.apollo.ApolloCall
    public Operation operation() {
        return this.operation;
    }

    private ApolloInterceptor.CallBack interceptorCallbackProxy() {
        return new ApolloInterceptor.CallBack() {
            /* class com.apollographql.apollo.internal.RealApolloCall.AnonymousClass1 */

            @Override // com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack
            public void onResponse(ApolloInterceptor.InterceptorResponse response) {
                Optional<ApolloCall.Callback<T>> callback = RealApolloCall.this.responseCallback();
                if (!callback.isPresent()) {
                    RealApolloCall.this.logger.d("onResponse for operation: %s. No callback present.", RealApolloCall.this.operation().name().name());
                    return;
                }
                callback.get().onResponse(response.parsedResponse.get());
            }

            @Override // com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack
            public void onFailure(ApolloException e) {
                Optional<ApolloCall.Callback<T>> callback = RealApolloCall.this.terminate();
                if (!callback.isPresent()) {
                    RealApolloCall.this.logger.d(e, "onFailure for operation: %s. No callback present.", RealApolloCall.this.operation().name().name());
                } else if (e instanceof ApolloHttpException) {
                    callback.get().onHttpError((ApolloHttpException) e);
                } else if (e instanceof ApolloParseException) {
                    callback.get().onParseError((ApolloParseException) e);
                } else if (e instanceof ApolloNetworkException) {
                    callback.get().onNetworkError((ApolloNetworkException) e);
                } else {
                    callback.get().onFailure(e);
                }
            }

            @Override // com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack
            public void onCompleted() {
                Optional<ApolloCall.Callback<T>> callback = RealApolloCall.this.terminate();
                if (RealApolloCall.this.queryReFetcher.isPresent()) {
                    RealApolloCall.this.queryReFetcher.get().refetch();
                }
                if (!callback.isPresent()) {
                    RealApolloCall.this.logger.d("onCompleted for operation: %s. No callback present.", RealApolloCall.this.operation().name().name());
                    return;
                }
                callback.get().onStatusEvent(ApolloCall.StatusEvent.COMPLETED);
            }

            @Override // com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack
            public void onFetch(final ApolloInterceptor.FetchSourceType sourceType) {
                RealApolloCall.this.responseCallback().apply(new Action<ApolloCall.Callback<T>>() {

                    public void apply(ApolloCall.Callback<T> callback) {
                        int i = AnonymousClass3.$SwitchMap$com$apollographql$apollo$interceptor$ApolloInterceptor$FetchSourceType[sourceType.ordinal()];
                        if (i == 1) {
                            callback.onStatusEvent(ApolloCall.StatusEvent.FETCH_CACHE);
                        } else if (i == 2) {
                            callback.onStatusEvent(ApolloCall.StatusEvent.FETCH_NETWORK);
                        }
                    }
                });
            }
        };
    }

    /* access modifiers changed from: package-private */
    /* renamed from: com.apollographql.apollo.internal.RealApolloCall$3  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass3 {
        static final /* synthetic */ int[] $SwitchMap$com$apollographql$apollo$interceptor$ApolloInterceptor$FetchSourceType;
        static final /* synthetic */ int[] $SwitchMap$com$apollographql$apollo$internal$CallState;

        static {
            int[] iArr = new int[ApolloInterceptor.FetchSourceType.values().length];
            $SwitchMap$com$apollographql$apollo$interceptor$ApolloInterceptor$FetchSourceType = iArr;
            try {
                iArr[ApolloInterceptor.FetchSourceType.CACHE.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                $SwitchMap$com$apollographql$apollo$interceptor$ApolloInterceptor$FetchSourceType[ApolloInterceptor.FetchSourceType.NETWORK.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            int[] iArr2 = new int[CallState.values().length];
            $SwitchMap$com$apollographql$apollo$internal$CallState = iArr2;
            try {
                iArr2[CallState.ACTIVE.ordinal()] = 1;
            } catch (NoSuchFieldError e3) {
            }
            try {
                $SwitchMap$com$apollographql$apollo$internal$CallState[CallState.IDLE.ordinal()] = 2;
            } catch (NoSuchFieldError e4) {
            }
            try {
                $SwitchMap$com$apollographql$apollo$internal$CallState[CallState.CANCELED.ordinal()] = 3;
            } catch (NoSuchFieldError e5) {
            }
            try {
                $SwitchMap$com$apollographql$apollo$internal$CallState[CallState.TERMINATED.ordinal()] = 4;
            } catch (NoSuchFieldError e6) {
            }
        }
    }

    @Override // com.apollographql.apollo.ApolloQueryCall, com.apollographql.apollo.ApolloCall, com.apollographql.apollo.ApolloMutationCall
    public Builder<T> toBuilder() {
        return (Builder<T>) builder().operation(this.operation).serverUrl(this.serverUrl).httpCallFactory(this.httpCallFactory).httpCache(this.httpCache).httpCachePolicy(this.httpCachePolicy).scalarTypeAdapters(this.scalarTypeAdapters).apolloStore(this.apolloStore).cacheHeaders(this.cacheHeaders).requestHeaders(this.requestHeaders).responseFetcher(this.responseFetcher).dispatcher(this.dispatcher).logger(this.logger).applicationInterceptors(this.applicationInterceptors).applicationInterceptorFactories(this.applicationInterceptorFactories).autoPersistedOperationsInterceptorFactory(this.autoPersistedOperationsInterceptorFactory).tracker(this.tracker).refetchQueryNames(this.refetchQueryNames).refetchQueries(this.refetchQueries).enableAutoPersistedQueries(this.enableAutoPersistedQueries).useHttpGetMethodForQueries(this.useHttpGetMethodForQueries).useHttpGetMethodForPersistedQueries(this.useHttpGetMethodForPersistedQueries).optimisticUpdates(this.optimisticUpdates).writeToNormalizedCacheAsynchronously(this.writeToNormalizedCacheAsynchronously);
    }

    private synchronized void activate(Optional<ApolloCall.Callback<T>> callback) {
        int i = AnonymousClass3.$SwitchMap$com$apollographql$apollo$internal$CallState[this.state.get().ordinal()];
        if (i != 1) {
            if (i == 2) {
                this.originalCallback.set(callback.orNull());
                this.tracker.registerCall(this);
                callback.apply(new Action<ApolloCall.Callback<T>>() {
                    /* class com.apollographql.apollo.internal.RealApolloCall.AnonymousClass2 */


                    public void apply(ApolloCall.Callback<T> callback) {
                        callback.onStatusEvent(ApolloCall.StatusEvent.SCHEDULED);
                    }
                });
                this.state.set(CallState.ACTIVE);
            } else if (i == 3) {
                throw new ApolloCanceledException();
            } else if (i != 4) {
                throw new IllegalStateException("Unknown state");
            }
        }
        throw new IllegalStateException("Already Executed");
    }

    /* access modifiers changed from: package-private */
    public synchronized Optional<ApolloCall.Callback<T>> responseCallback() {
        int i = AnonymousClass3.$SwitchMap$com$apollographql$apollo$internal$CallState[this.state.get().ordinal()];
        if (i != 1) {
            if (i != 2) {
                if (i != 3) {
                    if (i != 4) {
                        throw new IllegalStateException("Unknown state");
                    }
                }
            }
            throw new IllegalStateException(CallState.IllegalStateMessage.forCurrentState(this.state.get()).expected(CallState.ACTIVE, CallState.CANCELED));
        }
        return Optional.fromNullable(this.originalCallback.get());
    }

    /* access modifiers changed from: package-private */
    public synchronized Optional<ApolloCall.Callback<T>> terminate() {
        int i = AnonymousClass3.$SwitchMap$com$apollographql$apollo$internal$CallState[this.state.get().ordinal()];
        if (i != 1) {
            if (i != 2) {
                if (i == 3) {
                    return Optional.fromNullable(this.originalCallback.getAndSet(null));
                } else if (i != 4) {
                    throw new IllegalStateException("Unknown state");
                }
            }
            throw new IllegalStateException(CallState.IllegalStateMessage.forCurrentState(this.state.get()).expected(CallState.ACTIVE, CallState.CANCELED));
        }
        this.tracker.unregisterCall(this);
        this.state.set(CallState.TERMINATED);
        return Optional.fromNullable(this.originalCallback.getAndSet(null));
    }

    private ApolloInterceptorChain prepareInterceptorChain(Operation operation2) {
        HttpCachePolicy.Policy httpCachePolicy2 = operation2 instanceof Query ? this.httpCachePolicy : null;
        ResponseFieldMapper responseFieldMapper = operation2.responseFieldMapper();
        List<ApolloInterceptor> interceptors = new ArrayList<>();
        for (ApolloInterceptorFactory factory : this.applicationInterceptorFactories) {
            ApolloInterceptor interceptor = factory.newInterceptor(this.logger, operation2);
            if (interceptor != null) {
                interceptors.add(interceptor);
            }
        }
        interceptors.addAll(this.applicationInterceptors);
        interceptors.add(this.responseFetcher.provideInterceptor(this.logger));
        interceptors.add(new ApolloCacheInterceptor(this.apolloStore, responseFieldMapper, this.dispatcher, this.logger, this.writeToNormalizedCacheAsynchronously));
        ApolloInterceptorFactory apolloInterceptorFactory = this.autoPersistedOperationsInterceptorFactory;
        if (apolloInterceptorFactory != null) {
            ApolloInterceptor interceptor2 = apolloInterceptorFactory.newInterceptor(this.logger, operation2);
            if (interceptor2 != null) {
                interceptors.add(interceptor2);
            }
        } else if (this.enableAutoPersistedQueries && ((operation2 instanceof Query) || (operation2 instanceof Mutation))) {
            interceptors.add(new ApolloAutoPersistedOperationInterceptor(this.logger, this.useHttpGetMethodForPersistedQueries && !(operation2 instanceof Mutation)));
        }
        interceptors.add(new ApolloParseInterceptor(this.httpCache, this.apolloStore.networkResponseNormalizer(), responseFieldMapper, this.scalarTypeAdapters, this.logger));
        interceptors.add(new ApolloServerInterceptor(this.serverUrl, this.httpCallFactory, httpCachePolicy2, false, this.scalarTypeAdapters, this.logger));
        return new RealApolloInterceptorChain(interceptors);
    }

    public static final class Builder<T> implements ApolloQueryCall.Builder<T>, ApolloMutationCall.Builder<T> {
        ApolloStore apolloStore;
        List<ApolloInterceptorFactory> applicationInterceptorFactories;
        List<ApolloInterceptor> applicationInterceptors;
        ApolloInterceptorFactory autoPersistedOperationsInterceptorFactory;
        CacheHeaders cacheHeaders;
        Executor dispatcher;
        boolean enableAutoPersistedQueries;
        HttpCache httpCache;
        HttpCachePolicy.Policy httpCachePolicy;
        Call.Factory httpCallFactory;
        ApolloLogger logger;
        Operation operation;
        Optional<Operation.Data> optimisticUpdates = Optional.absent();
        List<Query> refetchQueries = Collections.emptyList();
        List<OperationName> refetchQueryNames = Collections.emptyList();
        RequestHeaders requestHeaders = RequestHeaders.NONE;
        ResponseFetcher responseFetcher;
        ScalarTypeAdapters scalarTypeAdapters;
        HttpUrl serverUrl;
        ApolloCallTracker tracker;
        boolean useHttpGetMethodForPersistedQueries;
        boolean useHttpGetMethodForQueries;
        boolean writeToNormalizedCacheAsynchronously;

        public Builder<T> operation(Operation operation2) {
            this.operation = operation2;
            return this;
        }

        public Builder<T> serverUrl(HttpUrl serverUrl2) {
            this.serverUrl = serverUrl2;
            return this;
        }

        public Builder<T> httpCallFactory(Call.Factory httpCallFactory2) {
            this.httpCallFactory = httpCallFactory2;
            return this;
        }

        public Builder<T> httpCache(HttpCache httpCache2) {
            this.httpCache = httpCache2;
            return this;
        }

        @Deprecated
        public Builder<T> responseFieldMapperFactory(ResponseFieldMapperFactory responseFieldMapperFactory) {
            return this;
        }

        public Builder<T> scalarTypeAdapters(ScalarTypeAdapters scalarTypeAdapters2) {
            this.scalarTypeAdapters = scalarTypeAdapters2;
            return this;
        }

        public Builder<T> apolloStore(ApolloStore apolloStore2) {
            this.apolloStore = apolloStore2;
            return this;
        }

        @Override // com.apollographql.apollo.ApolloMutationCall.Builder, com.apollographql.apollo.ApolloCall.Builder, com.apollographql.apollo.ApolloQueryCall.Builder
        public Builder<T> cacheHeaders(CacheHeaders cacheHeaders2) {
            this.cacheHeaders = cacheHeaders2;
            return this;
        }

        @Override // com.apollographql.apollo.ApolloQueryCall.Builder
        public Builder<T> httpCachePolicy(HttpCachePolicy.Policy httpCachePolicy2) {
            this.httpCachePolicy = httpCachePolicy2;
            return this;
        }

        @Override // com.apollographql.apollo.ApolloQueryCall.Builder
        public Builder<T> responseFetcher(ResponseFetcher responseFetcher2) {
            this.responseFetcher = responseFetcher2;
            return this;
        }

        @Override // com.apollographql.apollo.ApolloMutationCall.Builder, com.apollographql.apollo.ApolloQueryCall.Builder
        public Builder<T> requestHeaders(RequestHeaders requestHeaders2) {
            this.requestHeaders = requestHeaders2;
            return this;
        }

        @Override // com.apollographql.apollo.ApolloMutationCall.Builder
        public Builder<T> refetchQueryNames(List<OperationName> refetchQueryNames2) {
            this.refetchQueryNames = new ArrayList(refetchQueryNames2);
            return this;
        }

        @Override // com.apollographql.apollo.ApolloMutationCall.Builder
        public Builder<T> refetchQueries(List<Query> refetchQueries2) {
            this.refetchQueries = new ArrayList(refetchQueries2);
            return this;
        }

        public Builder<T> dispatcher(Executor dispatcher2) {
            this.dispatcher = dispatcher2;
            return this;
        }

        public Builder<T> logger(ApolloLogger logger2) {
            this.logger = logger2;
            return this;
        }

        public Builder<T> tracker(ApolloCallTracker tracker2) {
            this.tracker = tracker2;
            return this;
        }

        public Builder<T> applicationInterceptors(List<ApolloInterceptor> applicationInterceptors2) {
            this.applicationInterceptors = applicationInterceptors2;
            return this;
        }

        public Builder<T> applicationInterceptorFactories(List<ApolloInterceptorFactory> applicationInterceptorFactories2) {
            this.applicationInterceptorFactories = applicationInterceptorFactories2;
            return this;
        }

        public Builder<T> autoPersistedOperationsInterceptorFactory(ApolloInterceptorFactory interceptorFactory) {
            this.autoPersistedOperationsInterceptorFactory = interceptorFactory;
            return this;
        }

        public Builder<T> enableAutoPersistedQueries(boolean enableAutoPersistedQueries2) {
            this.enableAutoPersistedQueries = enableAutoPersistedQueries2;
            return this;
        }

        public Builder<T> optimisticUpdates(Optional<Operation.Data> optimisticUpdates2) {
            this.optimisticUpdates = optimisticUpdates2;
            return this;
        }

        public Builder<T> useHttpGetMethodForQueries(boolean useHttpGetMethodForQueries2) {
            this.useHttpGetMethodForQueries = useHttpGetMethodForQueries2;
            return this;
        }

        public Builder<T> useHttpGetMethodForPersistedQueries(boolean useHttpGetMethodForPersistedQueries2) {
            this.useHttpGetMethodForPersistedQueries = useHttpGetMethodForPersistedQueries2;
            return this;
        }

        public Builder<T> writeToNormalizedCacheAsynchronously(boolean writeToNormalizedCacheAsynchronously2) {
            this.writeToNormalizedCacheAsynchronously = writeToNormalizedCacheAsynchronously2;
            return this;
        }

        Builder() {
        }

        @Override // com.apollographql.apollo.ApolloMutationCall.Builder, com.apollographql.apollo.ApolloCall.Builder, com.apollographql.apollo.ApolloQueryCall.Builder
        public RealApolloCall<T> build() {
            return new RealApolloCall<>(this);
        }
    }
}
